package com.oa.service;

import com.oa.dao.AttendanceDao;
import com.oa.dao.impl.AttendanceDaoImpl;
import com.oa.entity.Attendance;
import com.oa.util.PageUtil;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/7/5 10:05
 **/
public class AttendanceServiceImpl implements AttendanceService {

	AttendanceDao attendanceDao = new AttendanceDaoImpl();

	@Override
	public List<Attendance> findAll() {
		return attendanceDao.findAll();
	}

	@Override
	public List<Attendance> findPage(PageUtil<Attendance> pageUtil) {
		return attendanceDao.findAll(pageUtil.getBeginIndex(), pageUtil.getShowSize());
	}

	@Override
	public List<Attendance> findParam(String empNamem, String time) {
		return attendanceDao.findParam(empNamem, time);
	}

	@Override
	public int add(Attendance attendance) {
		return 0;
	}

	@Override
	public int addSignInTime(int empId) {
		Attendance attendance = new Attendance();
		attendance.setId(empId); //员工编号

		String time = LocalDate.now().toString() +" "+ LocalTime.now().toString();
		attendance.setSignInTime(time);

		return attendanceDao.add(attendance);
	}

	@Override
	public int addSignOutTime(int empId) {
		Attendance attendance = new Attendance();
		attendance.setId(empId); //员工编号

		String time = LocalDate.now().toString() +" "+ LocalTime.now().toString();
		attendance.setSignOutTime(time);

		return attendanceDao.add(attendance);
	}
}
